<template>
  <ContentWrap>
    <template #header>
      <div class="card-header">
        <span class="card-title">参观者地域分布</span>
      </div>
    </template>
    <div class="card-content">
      <div class="chart" ref="chartRef"></div>
    </div>
  </ContentWrap>
</template>

<script lang="ts" setup>
import * as echarts from 'echarts'

const chartRef = shallowRef()
const myChart = shallowRef()
const initChart = () => {
  myChart.value = echarts.init(chartRef.value)
  const option = {
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'vertical',
      right: 'left',
      top: 'center'
    },
    color: ['#C3C5AC', '#FF8C46', '#D8C9A7', '#948064', '#F5EDD9', '#AB9266'],
    series: [
      {
        type: 'pie',
        radius: '50%',
        data: [
          { value: 1048, name: '东北地区' },
          { value: 735, name: '华北地区' },
          { value: 580, name: '华东地区' },
          { value: 484, name: '中南地区' },
          { value: 300, name: '西北地区' },
          { value: 300, name: '西南地区' },
        ],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  }
  myChart.value.setOption(option)
}
onMounted(() => {
  initChart() 
})
</script>

<style lang="scss" scoped>
.card-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .card-title {
    font-weight: bold;
    line-height: 32px;
  }
  .more {
    font-size: 14px;
  }
  :deep(.el-tabs__header) {
    margin: 0;
  }
}
.card-content {
  padding: 0 10px;
}
.chart {
  width: 100%;
  height: 220px;
}
:deep(.el-card__header) {
  padding: 10px;
}
</style>
